package com.swizipuremvc.core
{


	import org.puremvc.as3.multicore.core.Controller;
	import org.puremvc.as3.multicore.interfaces.ICommand;
	import org.puremvc.as3.multicore.interfaces.IController;
	import org.puremvc.as3.multicore.interfaces.INotification;

	public class ApplicationController extends Controller
	{
		private static var key:String;

		private var instance:ApplicationController;

		public function ApplicationController(key:String)
		{
			key = key;
			super(key);
		}


		override public function executeCommand(note:INotification):void
		{
			var commandClassRef:Class = commandMap[note.getName()];
			if (commandClassRef == null)
				return;
			var commandInstance:ICommand = new commandClassRef();
		//	injectionManager.processInjection(commandInstance);
			commandInstance.execute(note);
		}

		override protected function initializeController():void
		{
			view = ApplicationView.getInstance(key);
		}

		/*private function get injectionManager():InjectionManager
		{
			return (ApplicationFacade.getInstance(key) as ApplicationFacade).injectionManager;
		}*/

		public static function getInstance(key:String):IController
		{
			if (instanceMap[key] == null)
				instanceMap[key] = new Controller(key);
			return instanceMap[key];
		}
	}
}
